package com.linjj.seckill.rabbitmq;

import com.linjj.seckill.config.RabbitMQConfig;
import com.linjj.seckill.redis.RedisService;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * 消息发送者
 * */
@Service
public class MessageSender {
    @Autowired
    private AmqpTemplate amqpTemplate ;
    public void sendSeckillMessage(SeckillMessage sm) {
        String msg = RedisService.beanToString(sm);
        amqpTemplate.convertAndSend(RabbitMQConfig.SECKILL_QUEUE, msg);
    }
}
